//Tue Mar  8 12:32:42 CST 2011
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

class ColorfulRabbits
{
public:

    int getMinimum(vector <int> v)
    {
        sort(v.begin(), v.end());
        int ret = v[0] + 1;
        int count = 1;
        for (int i = 1; i < v.size(); i++)
        {
            if (v[i] == 0) //Check if it's the only one.
            {
                ret++;
                continue;
            }
            /** If it's different from the previous one,
             * The new count should start.
             */
            if (v[i] != v[i - 1])
            {
                count = 1;
                ret += v[i] + 1;
            }
                /** If they are same, check how many groups could it be.
                 */
            else
            {
                count++;
                if (count >= v[i] + 1)
                {
                    count = 0;
                }
                if (count == 1)
                {
                    ret += v[i] + 1;
                }
            }
        }
        return ret;
    }
};
